<template>
    <div>
        <h1>显示页面</h1>
        应收 <input type="text" v-model="data.HPrice">
        实手 <input type="text" v-model="data.SPrice">
        <button value="查询" @click="show">查询</button>
        <table class="table table-bordered" border="1px">
            <tbody>
                <tr>
                    <td>用户信息</td>
                    <td>门店信息</td>
                    <td>应收款</td>
                    <td>实收款</td>
                    <td>现金收银信息</td>
                    <td>门店状态</td>
                    <td>操作</td>
                </tr>
                <tr v-for="a in info.list">
                    <td>{{ a.Username }}</td>
                    <td>{{ a.HContext }}</td>
                    <td>{{ a.HPrice }}</td>
                    <td>{{ a.SPrice }}</td>
                    <td>{{ a.Content }}</td>
                    <td>{{ a.State?"营业":"闭店" }}</td>
                    <td>
                        <button value="营业" class="btn btn-primary" @click="up(a.Id)" v-if="a.State != true ">营业</button>
                        <button value="闭店" class="btn btn-primary" @click="up(a.Id)" v-if="a.State != false">闭店</button>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import axios from 'axios';
import { useRouter } from 'vue-router'
const router = useRouter();

let data: any = ref({
    HPrice: 0,
    SPrice: 0,
    pageindex: 1,
    pageszie: 5,
})

let info: any = reactive({
    Hnum: 0,
    Ynum: 0,
    list: []
})
onMounted(() => {
    show();
})

const show = () => {
    axios({
        url: 'https://localhost:7056/api/Hotel/Show',
        method: 'get',
        params: data.value
    })
        .then((res) => {
            console.log(res.data);
            info.list = res.data.list;
        })
}

const up = (Id: any) => {
    axios({
        url: 'https://localhost:7056/api/Hotel/Update',
        method: 'put',
        params: {
            id: Id
        }
    })
        .then((res) => {
            if (res.data > 0) {
                alert('状态修改成功!');
                show();
                return;
            }
            else {
                alert('状态修改失败!');
                return;
            }
        })
}

</script>

<style scoped></style>